package com.cbtx.tablet.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter

/**
 * author : joker.peng
 * e-mail : joker@fiture.com
 * date   : 2021/7/5 12:11 PM
 * desc   :
 */
class BaseFragmentPagerAdapter : FragmentPagerAdapter {

    private val mFragmentList: List<Fragment>? = null
    private val titles: List<String>? = null


    constructor(fm: FragmentManager, fragments: List<Fragment>) : super(fm)
    constructor(fm: FragmentManager, fragments: List<Fragment>, titles: List<String>) : super(fm)

    override fun getItem(position: Int): Fragment {
        return mFragmentList!![position]
    }

    override fun getCount(): Int {
        return mFragmentList?.size ?: 0
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return if (titles == null || titles.size < position) {
            null
        } else titles[position]
    }

}